﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using Webdiyer.AspNetCore;
using PlatformNetCore.Entity;
using PlatformNetCore.IRepository;

namespace PlatformNetCore.Repository
{
    public class AdRepository : Repository<Ad>, IAdRepository
    {
        public AdRepository(PlatformContext dbContext) : base(dbContext)
        {

        }
        public override PagedList<Ad> GetPagedList(int pageIndex, int pageSize, Expression<Func<Ad, bool>> predicate)
        {
            return _dbContext.Ad.Where(predicate).OrderByDescending(m => m.AddDate).ToPagedList(pageIndex, pageSize);
        }
        public override IEnumerable<Ad> GetList(Expression<Func<Ad, bool>> predicate)
        {
            return _dbContext.Ad.Where(predicate).OrderBy(m => m.SortNo);
        }
    }
}
